package 博客管理系统;

import javax.swing.*;
import java.awt.color.*;
import java.awt.*;
import java.awt.event.*;
public class CommFrame extends JFrame implements ActionListener{
    JMenuBar bar;
    JMenu menu;
    JMenuItem scanItem,deleteItem,updateItem,insertItem,searchItem;
    Scan_user scan;//查看用户信息
    Insert_user insert;//插入学生信息
    del_user delete;//删除用户信息
    Update_user update;//更新用户信息
    Scan_bk scan1;//查看博客信息
    Del_bk delete1;//删除博客信息
    Update_bk update1;//更新博客信息

    CardLayout card=null;
    JPanel pCenter;
    CommFrame(){
        setLayout(new FlowLayout());
        scanItem=new JMenuItem("查看");
        insertItem =new JMenuItem("添加");
        deleteItem=new JMenuItem("删除");
        updateItem=new JMenuItem("更新");
        bar=new JMenuBar();
        menu=new JMenu("菜单");
        menu.add(scanItem);
        menu.add(deleteItem);
        menu.add(updateItem);
        menu.add(insertItem);
        bar.add(menu);
        setJMenuBar(bar);
        scanItem.addActionListener(this);
        deleteItem.addActionListener(this);
        updateItem.addActionListener(this);
        insertItem.addActionListener(this);
        scan=new Scan_user();
        insert=new Insert_user();
        update=new Update_user();
        delete=new del_user();
        scan1=new Scan_bk();
        update1=new Update_bk();
        delete1=new Del_bk();
        card=new CardLayout();
        pCenter=new JPanel();
        pCenter.setLayout(card);
        pCenter.add("scanItem", scan);
        pCenter.add("deleteItem",delete);
        pCenter.add("updateItem",update);



        add(pCenter,BorderLayout.SOUTH);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        setBounds(400,150,550,400);
        setTitle("博客管理系统");
        validate();
    }
    public void actionPerformed(ActionEvent e){
        if(e.getSource()==scanItem)
            card.show(pCenter, "scanItem");
        else if(e.getSource()==deleteItem)
            card.show(pCenter, "deleteItem");
        else if(e.getSource()==updateItem)
            card.show(pCenter, "updateItem");
        else if(e.getSource()==insertItem)
            card.show(pCenter, "insertItem");
    }

    public static void main(String[] args) {
        new CommFrame();
    }
}

